<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="shortcut icon" type="text/css" th:href="@{/images/favicon.ico}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/css_x/centro/pintuer.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/css_x/centro/admin.css}">
    <script type="text/javascript" th:src="@{/js/js_x/fondo/jquery.js}"></script>
    <script type="text/javascript" th:src="@{/js/js_x/reservation/pintuer.js}"></script>
    <script type="text/javascript" th:src="@{/js/js_x/abanderar/index.js}"></script>
    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/view.css}"/>
</head>
<body>

    <div class="panel-head"><strong>历史订单</strong></div>
    <form class="panel admin-panel" action="#">
        <div class="padding border-bottom">
            <ul class="search">
                <if condition="$iscid eq 1">
                    <div class="form-group">
                        <div class="field">
                            <select name="cid" class="input w50">
                                <option value="">请选择分类</option>
                                <option value="">PCB</option>
                                <option value="">快捷打样</option>
                            </select>
                            <div class="tips"></div>
                        </div>	<a href="#" class="button border-main" >搜索</a>
                    </div>
                </if>
            </ul>
        </div>
    </form>



<form th:action="@{/a/u/delete}" method="post">
<table class="table table-hover text-center">
    <tr>
        <th>选项</th>
        <th>姓名</th>
        <th>公司</th>
        <th>订单时间</th>
        <th>价格</th>
        <th>订单编号</th>
        <th>操作</th>       
    </tr>
    <tr th:each="demo:${list}" >
        <td><input type="checkbox" name="cks" th:value="${demo.id}"/></td>
        <td th:text="${demo.userName}"></td>
        <td th:text="${demo.company}"></td>
        <td th:text="${#calendars.format(demo.createTime,'yyyy-MM-dd HH:mm:ss') }"></td>
        <td th:text="${demo.price2}"></td>
        <td th:text="${demo.orderNumber}"></td>
        <td><div class="button-group">
            <a class="button border-red" href="Listrovalue.html" th:href="@{/a/u/save(id=${demo.id})}">详情</a>
        </div></td>
    </tr>
    <tr>
		<td style="text-align: left; padding: 19px 0; padding-left: 20px;"><input
			type="checkbox" name="obj" onclick="checkAll(obj)" />全选</td>
    <td colspan="13" style="text-align:left;padding-left:20px;">
        <a href="javascript:void(0)" class="button border-blue"
           style="padding: 5px 15px;" onclick="delStu()">删除</a></td></tr>
    <td colspan="13" style="text-align: left; padding-left: 20px;"></td>
</table></form>
  <div id="pagination" style="text-align: center"></div>
  </div>
  <script type="text/javascript" th:src="@{/assets/layui.all.js}"></script>
<script th:inline="javascript">
    function checkAll(obj){
        //1.获取所有的td中的checkbox
        var cks = document.getElementsByName("cks");

        //2.循环遍历.
        if(obj.checked){
            for(var i=0;i<cks.length;i++){
                cks[i].checked = true;
            }
        }else{
            for(var i=0;i<cks.length;i++){
                cks[i].checked = false;
            }
        }
    }

    function delStu(){

        //1.确定是否勾选了
        var count = 0;

        //定义一个变量,用来拼接checkbox的value
        var sids="";

        //1.获取所有的td中的checkbox
        var cks = document.getElementsByName("cks");

        //2.遍历
        for(var i=0;i<cks.length;i++){
            if(cks[i].checked){
                count++;
                sids+=cks[i].value+",";
            }
        }
        //3.判断...
        if(count==0){
            //说明没有勾选的.
            alert("对不起!请您先选择需要删除的信息!");
            return;
        }

        //4.选了.
        var flag = window.confirm("确定删除吗?");//返回是true-确定

        //5.判断
        if(flag){
            //发送到删除学生的action
            var contextPath = [[${#request.getContextPath()}]];
            window.location.href=contextPath+"/a/u/delete?sids="+sids.substring(0,sids.length-1);
        }
    }
</script>





  <script th:inline="javascript">
      /*<![CDATA[*/
      var count = [[${count}]];//总记录数
      var curr = [[${curr}]];//当前页
      var contextPath = [[${#request.getContextPath()}]]; //获取当前应用路径
      /*]]>*/
  </script>
  <script type="text/javascript">
      layui.use('laypage', function(){
          var laypage = layui.laypage;

          //执行一个laypage实例
          laypage.render({
              elem: 'pagination' //注意，这里的 data 是 ID，不用加 # 号
              ,count: count //数据总数，从服务端得到
              ,curr: curr
              ,limit: 4
              ,jump: function(obj, first){
                  //obj包含了当前分页的所有参数，比如：
                  // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                  // console.log(obj.limit); //得到每页显示的条数

                  //首次不执行
                  if(!first){
                      window.location.href = contextPath + "/a/u/listory?page=" + (obj.curr) + "&size=" + obj.limit
                  }
              }
          });
      });
  </script>
</body></html>